<template>
  <div>
    <br/>
    <div>
      <el-form  :inline="true" :model="A">
            <el-form-item prop="" label="文章标题：">
                <el-input v-model="A.htitle" placeholder="请输入内容"  ></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="success" icon="el-icon-search" @click="Heamhc()"></el-button>
            </el-form-item>
            <el-button type="primary" style="margin-left: 300px" @click="tiajia()">添加健康百科文章</el-button>
        </el-form>
    </div>

      <div>
          <el-table border :data="Data.slice((currentPage-1)*pagesize,currentPage*pagesize)" style="width: 100%">
              <el-table-column prop="htitle" label="文章标题" ></el-table-column>
              <el-table-column prop="himage" label="缩略图" align="center">
          <template slot-scope="scope">            
            <img :src="scope.row.himage"  min-width="70" height="70" />
          </template>  
        </el-table-column>
              <el-table-column prop="hauthor" label="作者" ></el-table-column>
              <el-table-column prop="hcontent" label="内容" width="400" :show-overflow-tooltip="true" ></el-table-column>
              <el-table-column prop="createTime" label="操作时间"  > </el-table-column>
            <el-table-column label="操作" v-slot="a">
              <el-button type="primary" size="mini" @click="xiugai(a.row)">修改</el-button>
              <el-button type="primary" size="mini" @click="shanchu(a.row)">删除</el-button>
            </el-table-column>
          </el-table>
          <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[3, 5, 7]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="Data.length">
        </el-pagination>
      </div>
      <div>
      <el-dialog title="是否删除" :visible.sync="delmtk" :model="del">
        <el-button type="primary" @click="mtkHealth()">确定</el-button>
        <el-button type="primary" @click="delmtk=false" >取消</el-button>
      </el-dialog>
    </div>
  </div>
</template>

<script>
export default {
    data(){
        return{
            Data:[],
            upd:{},
            delmtk:false,
            del:{},
            A:{htitle:''},
            headertitle: "",
            centerDialogVisible:false,
            pagesize:3,
            currentPage:1,
        }
    },
    created(){
        this.findHealthAll()
    },
    methods:{
        findHealthAll(){
            this.$axios.get("/user/user/doctor/ren/findHealthAll").then(res=>{
                this.Data=res.data.data.list
            })
        },
        tianjia(){
            this.$router.push({ path: "/AddHealth" });
        },
        xiugai(row){
          this.$router.push({path: "/UpdHealthy",query: {row: row}});
          this.upd = { ...row };
        },
        shanchu(row){
          this.delmtk=true;
          this.del={...row}
        },
        mtkHealth(row){
          this.$axios.post("/user/user/doctor/ren/mtkHealth",this.del).then(res=>{
            this.delmtk=false;
            this.findHealthAll();
        })
        },
        Heamhc(){
            this.$axios.get("/user/user/doctor/ren/Heamhc",{params:{htitle:this.A.htitle}}).then(res=>{
                this.Data = res.data.data.list;
          })
        },
         handleSizeChange(size) {
            this.pagesize = size;
        },
        handleCurrentChange(currentPage) {
                this.currentPage = currentPage;
      }
    }
}
</script>

<style>

</style>
